package com.example.bilibili.controller;

import com.example.bilibili.domain.BiliVideo;
import com.example.bilibili.util.UploadUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
public class UserPhotoController {

    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    @ResponseBody
    public String testUpload(@RequestParam("file") MultipartFile file,Long uploaderid) {
        BiliVideo video=new BiliVideo();
        video.setUploaderid(uploaderid);
        UploadUtil uploadUtil = new UploadUtil();
        String fileName = "";
        if (uploadUtil.doUpload(file, "uploadvid")) {
            fileName = uploadUtil.getUploadFile();
        } else {
            fileName = "file";
        }

        return fileName;
    }
}